// pages/my/myinfo/myinfo.js
const app = getApp()
const $ = app.globalData
Page({
	data: {
		age: ["我也不知道", "男", "女"],
		ageindex: 0,
		date: 0,
		name:''
	},
	open2:function(e){
		this.setData({
			name: e.detail.value
		})
	},
	bindPickerChange: function(e) {
		this.setData({
			ageindex: e.detail.value
		})
	},
	bindDateChange: function(e) {
		this.setData({
			date: e.detail.value
		})
	},
	gotologin:function(){
		var that = this
		var name = that.data.name
		if(name == ''){
			wx.showToast({
				icon:"none",
				title: "请输入昵称",
				duration: 3000,
			})
		}else{
			wx.request({
				url:$.AdminUrl+"/YApi/changeMyName",
				data:{
					customerid:that.data.userinfo.id,
					name:name
				},
				success:function(data){
					if(data.data.code){
						wx.showToast({
							icon:"none",
							title: "修改成功",
							duration: 3000,
						})
					}else{
						wx.showToast({
							icon:"none",
							title: data.data.msg,
							duration: 3000,
						})
					}
				}
			})
		}
	},
	onLoad: function(options) {
		// 获取用户信息
		var userinfo = wx.getStorageSync('userinfo')
		this.setData({
			userinfo: userinfo,
			name:userinfo.name
		})
	},
})
